﻿using SIE.SCADA.Common.Log;
using SIE.SCADA.ZemtDemo.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SIE.SCADA.ZemtDemo.View
{
    /// <summary>
    /// EquipmentView.xaml 的交互逻辑
    /// </summary>
    public partial class UserRoleView : UserControl
    {
        private UserRoleViewModel viewModel;
        public UserRoleView()
        {
            InitializeComponent();
            viewModel = new UserRoleViewModel();
            this.DataContext = viewModel;
        }

        private void Query(object sender, RoutedEventArgs e)
        {
            //if (EquipmentCode.Text == null || EquipmentCode.Text == "")
            //{
            //    viewModel.Query();
            //}
            //else {

                //viewModel.Query(userid.Text, username.Text);

            //}

            try {
                viewModel.Query(userid.Text, username.Text);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);

            }
            


        }

        private void Delete(object sender, RoutedEventArgs e)
        {
            try
            {
                viewModel.Delete();
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);

            }
            
        }

        private void Add(object sender, RoutedEventArgs e)
        {
            try
            {
                viewModel.Add();
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);

            }
           
        }

        private void Modify(object sender, RoutedEventArgs e)
        {
            this.equipment.IsReadOnly = false;
        }

        private void Save(object sender, RoutedEventArgs e)
        {
            try
            {
                viewModel.Update();
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                Logger.Error(ex.StackTrace);

            }
            
        }
        /// <summary>
        /// KJF 2021033O 新增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GetEquipment_Click(object sender, RoutedEventArgs e)
        {
            
        }
    }
}
